package com.zhangfb95.crosschain.server.infra.data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangfb95.crosschain.server.infra.model.mapper.entity.ChainAccount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * @author zhangfubing
 * @since 2023/10/19
 */
@Mapper
public interface ChainAccountMapper extends BaseMapper<ChainAccount> {

    @Update("UPDATE chain_account SET is_default = 0 " +
            "WHERE user_id = #{userId} " +
            "AND chain_path = #{chainPath} " +
            "AND is_default = 1")
    void updateDefaultToFalse(@Param("userId") Long userId, @Param("chainPath") String chainPath);
}
